<template>
  <el-table :data="reportData" border>
    <el-table-column type="index" label="序号"></el-table-column>
    <el-table-column label="名称">
      <template #default="scope">
        <span v-if="scope.row.isFolder"
          ><i class="el-icon-folder"></i> {{ scope.row.name }}</span
        >
        <span v-else>{{ scope.row.name }}</span>
      </template>
    </el-table-column>
    <el-table-column label="创建人" prop="creator"></el-table-column>
    <el-table-column label="创建时间" prop="createTime"></el-table-column>
    <el-table-column label="操作">
      <template #default="scope">
        <span v-if="scope.row.isFolder">
          <el-button type="text" size="small" @click="renameFolder(scope.row)"
            >重命名</el-button
          >
          <el-button type="text" size="small" @click="editFolder(scope.row)"
            >编辑</el-button
          >
          <el-button
            type="text"
            size="small"
            @click="deleteFolder(scope.row)"
            style="color: red"
            >删除</el-button
          >
        </span>
        <span v-else>
          <el-button type="text" size="small" @click="moveReport(scope.row)"
            >移动</el-button
          >
          <el-button type="text" size="small" @click="editReport(scope.row)"
            >编辑</el-button
          >
          <el-button
            type="text"
            size="small"
            @click="deleteReport(scope.row)"
            style="color: red"
            >删除</el-button
          >
        </span>
      </template>
    </el-table-column>
  </el-table>
  <move-popup ref="MovePopupRef"></move-popup>
  <reset-name-popup ref="resetNamePopupRef"></reset-name-popup>
</template>
<script setup lang="ts">
import { ref } from "vue";
import MovePopup from "./move.vue"
import resetNamePopup from "./resetName.vue"
// 重命名文件夹方法
const resetNamePopupRef=ref(null)
const renameFolder = (folder: any) => {
  console.log(`重命名文件夹 ${folder.name}`);
  resetNamePopupRef.value.open()
};
// 移动报表方法
const MovePopupRef=ref(null)
const moveReport = (report: any) => {
  console.log(`移动报表 ${report.name}`);
  MovePopupRef.value.open()
};
const reportData=ref([])
const setData = (value:any)=>{
    console.log(value,"value))))))")
    reportData.value=value.value
}
// 编辑报表方法
const editReport = (report: any) => {
  console.log(`编辑报表 ${report.name}`);
};

// 删除报表方法
const deleteReport = (report: any) => {
  console.log(`删除报表 ${report.name}`);
};
// 编辑文件夹方法
const editFolder = (folder: any) => {
  console.log(`编辑文件夹 ${folder.name}`);
};

// 删除文件夹方法
const deleteFolder = (folder: any) => {
  console.log(`删除文件夹 ${folder.name}`);
};
defineExpose({
    setData
});
</script>
